<template>
  <div class="orderItem">
    <img :src="orderItem.skuImage" alt="" />
    <div class="title">
      <nut-ellipsis
        direction="end"
        rows="2"
        :content="orderItem.skuTitle"
      ></nut-ellipsis
      ><span class="attr">{{ orderItem.skuAttr }}</span>
    </div>
    <div class="price">
      <nut-price :price="orderItem.price" size="normal" symbol="￥" />
      <span
        v-if="showRefundStatusName && !orderItem.showReturnDeliveryBtn"
        class="refund"
        >{{ orderItem.refundStatusName }}</span
      >
      <nut-button
        v-if="showApplyReturnBtn && orderItem.showApplyReturnBtn"
        type="default"
        @click="
          $router.push({
            path: '/order/return',
            query: { orderId: orderItem.orderId, orderItemId: orderItem.id },
          })
        "
        >申请售后</nut-button
      >
      <nut-button
        v-if="showReturnDeliveryBtn && orderItem.showReturnDeliveryBtn"
        type="default"
        @click="emits('returnDelivery', orderItem)"
        >去发货</nut-button
      >
      <span class="num"
        >x<span>{{ orderItem.quantity }}</span></span
      >
    </div>
  </div>
</template>

<script setup>
import { defineProps, defineEmits } from "vue";

// 属性
const props = defineProps({
  orderItem: {
    type: Object,
  },
  showApplyReturnBtn: {
    type: Boolean,
    default: false,
  },
  showReturnDeliveryBtn: {
    type: Boolean,
    default: false,
  },
  showRefundStatusName: {
    type: Boolean,
    default: false,
  },
});

// 方法
const emits = defineEmits(["returnDelivery"]);
</script>

<style lang="less" scoped>
.orderItem {
  display: flex;
  img {
    width: 80px;
    height: 80px;
  }
  .title {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
    margin: 0px 10px 0px 15px;
    font-size: 12px;
    .attr {
      font-size: 11px;
      margin-top: 5px;
      color: #aaa;
    }
  }
  .price {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0px 0px 0px 0px;
    .refund {
      color: #fa2c19;
    }
    .nut-price {
      color: #000;
    }
    .nut-button {
      margin-top: 5px;
      height: 20px;
      font-size: 12px;
      padding: 10px 10px;
      color: #000;
    }
    .num {
      display: flex;
      margin-top: 10px;
      font-size: 10px;
      span {
        margin: 0px 2px;
      }
    }
  }
}
</style>